<?php if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Products_model extends AppModel {

    var $_tablename = PRODUCTS;
    var $_primary_key = PRODUCTS_PRODUCT_ID;
    
    public function Products_model() {
        parent::AppModel();
    }

    function get_list($group_id = null, $limit = null, $offset = null, $sort_field = null, $sort_type = 0) {
        $condition = PRODUCTS_STATUS . ' = 1 ';
        if ($group_id)
            $condition .= ' AND ' . PRODUCTS_GROUP . ' = ' . $group_id;
        $res = parent::get_lists($condition, $limit, $offset, $sort_field, $sort_type);

        return $res;
    }

    function path() {
        return APPPATH . 'assets/admin/products/' . $this->admin_id . '/treasure_bags';
    }

    function get_by_id($product_id = null) {
        $cond = array(PRODUCTS_STATUS=>1,
            PRODUCTS_PRODUCT_ID=>$product_id);
        $this->db->where($cond);
        return $this->db->get($this->_tablename)->row();
    }
}

?>